import http from './http'
//const AUTH_TOKEN = "Authorization";

// http.setBaseUrl("http://localhost:9690");
http.setBaseUrl("https://yaxinda.bhujuz.cn");

		
http.beforeResponseFilter = function(res) {
	if (res.statusCode == 401 || (res.data.code && res.data.code == 401)) {
		uni.showToast({
			title: '登录超时',
			image: '../../static/icon/error.png',
			duration: 2000
		})
		// uni.removeStorageSync("token");
		// if(!res.data.code){
		// 	res.data.code = 401
		// }
	}
	return res;
}

function removeBusnissToken() {
	uni.removeStorageSync('businesstoken');
	setTimeout(function() {
		uni.redirectTo({
			url: '/pages/store/login'
		})
	}, 2000)

}

function removeWorkerToken() {
	uni.removeStorageSync('workerToken');
	setTimeout(function() {
		uni.redirectTo({
			url: '/pages/worker/login'
		})
	}, 2000)

}

function removeOriginToken() {
	uni.removeStorageSync("token");
	uni.removeStorageSync("userInfo");
	uni.removeStorageSync("isLogin");
	uni.removeStorageSync("userId");
		uni.redirectTo({
			// url: '/pages/index/index'
		})

}

let my = {
	'http': http,
}

export default my
